<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
?>
<div class="row" style="width:600px">
  <div class="col-lg-12">
    <section class="panel">
      <header class="panel-heading">搜索区域</header>
      <div class="panel-body">
        <div class="row text-small">
          <div class="col-sm-10">
            <div class="input-group">
              <input type="text" placeholder="请输入要查找的区域名称..." id="search-text" class="input-sm form-control" value="">
              <span class="input-group-btn">
              <input type="hidden" name="fid" id="fid" placeholder="" class="form-control" value="<?php echo $fid;?>" />
              <button type="button" id="search-btn" class="btn btn-sm btn-white">搜索</button>
              </span> </div>
          </div>
        </div>
      </div>
      <div class="table-responsive" id="show-data-list"></div>
    </section>
  </div>
</div>
<script>
var field='<?php echo $field;?>';
$(function(){
	var timeoutId;
	$("#search-text").keyup(function(){
		var title=$(this).val();
		if (title){
			clearTimeout(timeoutId);
            timeoutId = setTimeout(function(){
				$("#search-btn").click();
			},300);
		}
	});
	$("#search-btn").click(function(){
		var title=$("#search-text").val();
		if (!title){
			Msg.error('请输入关键字');
			return false;
		}
		loadData('<?php echo U('area/ajax',array('type'=>$type));?>',{"title":title,"fid":$("#fid").val()});
	})
	function loadData(url,data){
		Msg.loading();
		$.getJSON(url,data,function(result){
			Msg.hide();
			if (result.status==1){
				$("#show-data-list").html(result.data);
			}else{
				Msg.error(result.info);
			}	
		});	
	}
	$("#show-data-list").delegate(".set-area","click",function(){
		setArea($(this).attr('aid'),$(this).attr('aname'),field);
	});
	$("#show-data-list").delegate('#ajax_pagebox a','click',function(){
		loadData($(this).attr('rel'));
	});
})
</script>
